def count_words (filename):
    """计算一个文件大致包含多少单词"""
    try:
        with open(filename) as f_obj:
            contents = f_obj.read()
    except FileNotFoundError:
        pass
        print('The ' + filename + ' is not exist!')
    else:
        total = contents.split()
        print(len(total))

filenames = ['pi_digits.txt', 'guest.txt', 'ff.txt']
for filename in filenames:
    count_words(filename)
